package com.third.exception;

import com.third.entity.RestBean;
import jakarta.validation.ValidationException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 唐博文
 * @version 2023.1.2
 * @date 2023/10/23 16:38 星期一
 */
@Slf4j
@RestControllerAdvice
public class ValidationController {
    
    @ExceptionHandler(ValidationException.class)
    public RestBean<Void> validateException(ValidationException exception){
        log.warn("Resolve [{}: {}]",exception.getCause(),exception.getMessage());
        return RestBean.failure(400,"请求参数有误");
    }
    
    
}
